home *** CD-ROM | disk | FTP | other *** search
/ Megahits 3 / Megahits 3 (1994)(GTI - Rhein-Main-Soft)(DE)[!].iso / module / utilities / archives / k1ed_v5_31.lha / src / swap1.c < prev    next >
C/C++ Source or Header  |  1992-05-02  |  3KB  |  134 lines

  1. #include <exec/memory.h>
  2.  
  3. #include "inc.h"
  4. #include "defs.h"
  5. #include "req_manx_5.c"
  6. #include "zz_pointer.h"
  7.  
  8.  
  9. void ExternToIntern(void);
  10. void InternToExtern(void);
  11. void SwapInternExtern(void);
  12. int TestCard(void);
  13.  
  14. /**********************************************************************************/
  15. /***                                                                            ***/
  16. /**********************************************************************************/
  17.  
  18. void ExternToIntern(void)
  19. {
  20.     int chn;
  21.  
  22.     chn=WaitForK1();
  23.     if (chn == -1)
  24.     {
  25.         MyReq("Can't do that because K1 not present",NULL," Ok ");
  26.         goto Ende;
  27.     }
  28.  
  29.     if (!TestCard()) goto Ende;
  30.     MyReq("Not implemented, yet",NULL,"Resume");
  31.  
  32.     Ende: CLEAR_POINTER(win);
  33. }
  34.  
  35.     
  36. /**********************************************************************************/
  37. /***                                                                            ***/
  38. /**********************************************************************************/
  39.  
  40. void InternToExtern(void)
  41. {
  42.     int chn;
  43.  
  44.     chn=WaitForK1();
  45.     if (chn == -1)
  46.     {
  47.         MyReq("Can't do that because K1 not present",NULL," Ok ");
  48.         goto Ende;
  49.     }
  50.  
  51.     if (!TestCard()) goto Ende;
  52.     MyReq("Not implemented, yet",NULL,"Resume");
  53.  
  54.     Ende: CLEAR_POINTER(win);
  55. }
  56.  
  57. /**********************************************************************************/
  58. /***                                                                            ***/
  59. /**********************************************************************************/
  60.  
  61. void SwapInternExtern(void)
  62. {
  63.     int chn;
  64.  
  65.     chn=WaitForK1();
  66.     if (chn == -1)
  67.     {
  68.         MyReq("Can't do that because K1 not present",NULL," Ok ");
  69.         goto Ende;
  70.     }
  71.  
  72.     if (!TestCard()) goto Ende;
  73.     MyReq("Not implemented, yet",NULL,"Resume");
  74.  
  75.     Ende: CLEAR_POINTER(win);
  76. }
  77.  
  78. /**********************************************************************************/
  79. /***                                                                            ***/
  80. /**********************************************************************************/
  81.  
  82. int TestCard(void)
  83. {
  84.     int i,fo;
  85.     unsigned char buf[97];
  86.     char str[100];
  87.     FILE *fp,*fopen();
  88.  
  89.     fo=creat("ram:k1-bank",0666);
  90.     if (fo != -1)
  91.     {
  92.         buf[0]=MS_SYSEX; buf[1]=0x40; buf[2]=MASTERCHANNEL; buf[3]=0x20; 
  93.         buf[4]=0x00; buf[5]=0x03; buf[6]=0x00; buf[7]=1;
  94.  
  95.         for (i=0;i<=87;i++)    buf[8+i]=0x22;    /* Singlessound an externe Card schicken */
  96.         buf[96]=MS_EOX;                          /* und Reaktion abwarten */
  97.         PutMidiMsg(source,buf);
  98.         Delay(3);
  99.  
  100.         WaitPort(dest->DestPort);
  101.         if (packet = getpacket(dest)) 
  102.         {
  103.             if (write(fo,packet->MidiMsg,packet->Length) != packet->Length); 
  104.         }
  105.         close(fo);
  106.     }
  107.  
  108.     fp=fopen("ram:k1-bank","r");
  109.     for (i=0;i<=7;i++) str[i]=fgetc(fp);        /* Error-Code einlesen*/
  110.     fclose(fp);
  111.     DeleteFile("ram:k1-bank");
  112.     
  113.     if (str[3]==0x43)
  114.     {
  115.         MyReq("Sorry, there is no external card",NULL,"Go on");
  116.         return(FALSE);
  117.     }
  118.  
  119.     if (str[3]==0x42)
  120.     {
  121.         MyReq("Sorry, memory is write protected",NULL,"Go on");
  122.         return(FALSE);
  123.     }
  124.  
  125.     if (str[3]==0x41)
  126.     {
  127.         MyReq("Sorry, write error on card",NULL,"Go on");
  128.         return(FALSE);
  129.     }
  130.  
  131.     return(TRUE);
  132. }
  133.  
  134.